import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*
题目描述：把数组排成最小的数
方法：引入比较器快速解决问题
 */
public class E45 {
    public static void main(String[] args) {
        int[] numbers = {3,32,321};
        String res = PrintMinNumber(numbers);
        System.out.println(res);
    }

    public static String PrintMinNumber(int [] numbers) {
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < numbers.length; i++){
            list.add(numbers[i]);
        }
        Collections.sort(list, (o1, o2) -> {
            String str1 = o1 + "" + o2;
            String str2 = o2 + "" + o1;
            return str1.compareTo(str2);
        });

        StringBuilder sb = new StringBuilder();
        for(int a : list){
            sb.append(a);
        }
        return sb.toString();
    }
}
/*
321323
 */